package com.campus.shop.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.campus.shop.common.ConstantProperties;
import com.campus.shop.entity.GoodsMessage;
import com.campus.shop.mapper.MessageMapper;
import com.campus.shop.service.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;

/**
 * 服务实现类
 *
 * @author xr
 * @since 2023-12-362 17:03:51
 */
@Service
public class MessageServiceImpl extends ServiceImpl<MessageMapper, GoodsMessage> implements MessageService {
    @Autowired
    private MessageMapper messageMapper;

    @Override
    public HashMap<String, Object> getGoodsMessage(Integer goodsId, Integer page) {
            Integer offset = (page - 1) * 10;
            HashMap<String,Object> res = new HashMap<>();
            List<GoodsMessage> pageList = messageMapper.getPageList(ConstantProperties.limit, offset, goodsId);
            Integer total = messageMapper.getPageTotal(goodsId);
            res.put("list",pageList);
            res.put("total",total);
            return res;
    }
}


